package Year22_Month07.day07;

public class 移除链表元素 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode myhead = new ListNode(0);
        myhead.next = head;
        ListNode tmp = myhead;
        while(myhead.next != null){
            if(myhead.next.val == val){
                myhead.next = myhead.next.next;
            }else{
                myhead  = myhead.next;
            }
        }
        return tmp.next;
    }
}
